﻿using BaBaoFan.Modifier.Data;
using BaBaoFan.Modifier.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace BaBaoFan.Modifier.Service
{
    public class NavigationService : INavigationService
    {
        private readonly INavigationRepository navigationRepository;
        public NavigationService(INavigationRepository navigationRepository)
        {
            this.navigationRepository = navigationRepository;
        }
        public bool AddNavigationColumn(NavigationColumn navigationColumn)
        {
            return navigationRepository.AddNavigationColumn(navigationColumn);
        }

        public bool AddNavigationInfo(NavigationInfoEntity navigationInfo)
        {
            return navigationRepository.AddNavigationInfo(navigationInfo);
        }

        public bool DeleteNavigationColumns(IEnumerable<int> ids)
        {
            return navigationRepository.DeleteNavigationColumns(ids);
        }

        public bool DeleteNavigationInfos(IEnumerable<int> ids)
        {
            return navigationRepository.DeleteNavigationInfos(ids);
        }

        public IEnumerable<NavigationColumn> GetAllClasses()
        {
            return navigationRepository.GetAllClasses();
        }

        public IEnumerable<NavigationInfo> GetAllNavigationInfo()
        {
            return navigationRepository.GetAllNavigationInfo();
        }

        public IEnumerable<NavigationColumn> GetAllNavigationColumn()
        {
            return navigationRepository.GetAllNavigationColumn();
        }

        public IEnumerable<NavigationInfo> GetAllParentNavigation()
        {
            return navigationRepository.GetAllParentNavigation();
        }

        public NavigationInfoEntity GetNavigationById(int id)
        {
            return navigationRepository.GetNavigationById(id);
        }

        public NavigationColumn GetNavigationColumnById(int id)
        {
            return navigationRepository.GetNavigationColumnById(id);
        }

        public bool UpdateNavigationColumn(NavigationColumn navigationColumn)
        {
            return navigationRepository.UpdateNavigationColumn(navigationColumn);
        }

        public bool UpdateNavigationInfo(NavigationInfoEntity navigationInfo)
        {
            return navigationRepository.UpdateNavigationInfo(navigationInfo);
        }

        public IEnumerable<NavigationInfo> Search(NavigationCondition navigationCondition)
        {
            return navigationRepository.Search(navigationCondition);
        }

        public IEnumerable<NavigationInfo> GetNavigationByColumnId(NavigationCondition navigation)
        {
            if (navigation.ColumnId == "-1")//所有子集
                return navigationRepository.GetAllChildNavigation(navigation);
            else if (navigation.ColumnId == "-2") //其他（没有和关系表关联的）
                return navigationRepository.GetAllNavigationNotInColumn(navigation);
            else
                return navigationRepository.GetNavigationByColumnId(navigation);
        }
    }
}
